﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Threading;

namespace ClueOnline
{

    public partial class Form1 : Form
    {
        AboutBox1 theAboutForm = new AboutBox1();
        Thread serverThread, clientThread;

        public Form1()
        {
            InitializeComponent();
            
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {

        }

        private void exitToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            // Dont forget to close all sockets here. and stop all threads
            foreach(Thread t in Program.clientThreads)
            {
                
            }
            Application.Exit();
        }

        private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.Console.Out.WriteLine("Clicked about");
            theAboutForm.Show();

        }

        private void rulesToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void connectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            clientThread = new Thread(ClueOnline.Client.StartClient);
            Program.clientThreads.Add(clientThread);
            clientThread.Start();

        }

        private void disconnectToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void startServerToolStripMenuItem_Click(object sender, EventArgs e)
        {
            serverThread = new Thread(ClueOnline.Server.StartListening);
            serverThread.Start();
        }

        private void closeServerToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ClueOnline.Server.StopListening();
        }
        // http://www.yoda.arachsys.com/csharp/threads/shutdown.shtml
        
    }

}
